<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
  <!ENTITY nbsp "&#x00A0;">
]>
<xsl:stylesheet
	version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:msxml="urn:schemas-microsoft-com:xslt"
	xmlns:umbraco.library="urn:umbraco.library"
  	xmlns:c4u="urn:c4u"
	exclude-result-prefixes="msxml umbraco.library c4u">


  <xsl:output method="xml" omit-xml-declaration="yes" />

  <xsl:param name="currentPage"/>

  <!-- Input the documenttype you want here -->
  <xsl:variable name="level" select="1"/>

  <xsl:template match="/">

 <xsl:variable name="submitOK" select="umbraco.library:RequestForm('submitOK')"/>

<xsl:variable name="P" select="umbraco.library:RequestQueryString('p')"/>

    <xsl:for-each select="c4u:ProductDetail($P)">
      <form action="" method="post" enctype="multipart/form-data" id="contact-form">

        <p>
          <xsl:value-of select="@OurPrice"/>
        </p>
        <xsl:if test="@DefaultImage !=''">
          <xsl:element name="img">
            <xsl:attribute name="src">
              <xsl:value-of select="umbraco.library:GetMedia(@DefaultImage,'false')/data[@alias='umbracoFile']"/>
            </xsl:attribute>
            <xsl:attribute name="alt">
              <xsl:value-of select="@ProductName"/>
            </xsl:attribute>
          </xsl:element>
        </xsl:if>
        <xsl:value-of select="@ProductName"/>
        <xsl:value-of select="@ShortDescription"/><br />
	<label for="qty">Quantity:</label>
	<input type="textbox" name="qty" value="1" size="2"/>
        <input type="submit" name="addtocart" value="Add to Cart"/>
	<input type="hidden" name="productID" value="1" />
       <input type="hidden" name="submitOK" value="OK" />        
      </form>
<ul>
  <xsl:for-each select="./CategoryList/Category">
<li><xsl:value-of select="@CategoryName"/></li>
</xsl:for-each>
</ul>

    </xsl:for-each>


 <!-- Form has been submitted -->
    <xsl:if test="$submitOK='OK'">


<xsl:variable name="Quantity" select="umbraco.library:RequestForm('qty')"/>
<xsl:variable name="ProductID" select="umbraco.library:RequestForm('ProductID')"/>

<xsl:choose>
<xsl:when test="c4u:AddToCart($ProductID,$Quantity)='Success'">
    <!-- After sending Reload the Page -->
    <script language="JavaScript" type="text/javascript">
      document.location.href="/cart.aspx";
    </script>
    </xsl:when>
<xsl:otherwise>Error
</xsl:otherwise>
</xsl:choose>


</xsl:if>

  </xsl:template>

</xsl:stylesheet>